<?php
class JsController {
	public function teach(){
		if (empty($_GET['date'])){
			$time = date('G:i');
		}
		else{
			if ($_GET['date']==strtotime(date('Y-m-d'))){
				$time = date('G:i');
			}
			else{
				$time ='10:00';
			}
		}
		$data['date'] = Common::getGetStrValue('date');
		$data['time'] = $time;
		return $data;
	}
	public function reserveCourse(){
		$data = HttpServerManager::getCourseServer()->userGetCourseType();
		$type = json_encode($data['type']);
		return array('type'=>$type);
	}

	public function getCourseType(){
		$data = HttpServerManager::getCourseServer()->userGetCourseType();
		$type = json_encode($data['type']);
		return array('type'=>$type);
	}
	
	public function getCourse(){
		if(isset($_POST['course_type'])&&Common::is_number($_POST['course_type'])){
			$data = HttpServerManager::getCourseServer()->userGetCourse($_POST['course_type']);
			HttpServerManager::getCourseServer()->filterSummerActiver($data);
			$json_result = array();
			$json_result['success']='success';
			$json_result['data'] = 	$data['course'];	
			exit(json_encode($json_result));
		}
	}
	

	public function getChapter(){
		if(isset($_POST['deep'])&&$_POST['deep']=="2"){
			$course_type_id = $_POST['course_type'];
			$course = HttpServerManager::getCourseServer()->userGetCourse($course_type_id);//只有1个教程
			$course_id = 0;
			foreach($course['course'] as $key=>$value){
				$course_id = $key;
			}
			$courseInfo = HttpDaoManager::getCourseDao()->get($course_id);
			$data = HttpServerManager::getCourseServer()->userGetChapter($course_id);
			$data['course_name'] = $courseInfo['theme'];
			
		}else{//2
			$course_id = $_POST['course_id'];
			$data = HttpServerManager::getCourseServer()->userGetChapter($course_id);
			$courseInfo = HttpDaoManager::getCourseDao()->get($course_id);
			$data['course_name'] = $courseInfo['theme'];			
		}
		$json_result = array();
		$json_result['success']='success';
		$json_result['data'] = 	$data['chapter'];
		$json_result['course_name'] = 	$data['course_name'];
		exit(json_encode($json_result));
	}
	
	public function reserveCourse2(){
		$data = HttpServerManager::getCourseServer()->userGetCourse2();
		$type = json_encode($data['type']);
		$course = json_encode($data['course']);
		$chapter = json_encode($data['chapter']);
		return array('type'=>$type,'course'=>$course,'chapter'=>$chapter);
	}

}

?>